/*  recognzer.h
    
    Header file for the Recognzer class

    Nicholas Green
    Recognzer
*/

#ifndef RECOGNIZER_H
#define RECOGNIZER_H

#include <stdio.h>
#include <stdlib.h>
#include "lexeme.h"
#include "lex.h"

struct exit_exception { 
   int m_code;
   const char* m_type;
   const char* m_typeName;
   const char* m_expected;
   int m_line;
   exit_exception(int code, const char* type, const char* typeName,
     const char* expected, int line)
     :m_code(code), m_type(type), m_typeName(typeName),
     m_expected(expected), m_line(line)
   {
     printf("ILLEGAL\nError %d at line %d. (%s %s) not valid. Expecting %s.\n",
       m_code, m_line,m_type,m_typeName,m_expected);
     exit(m_code);
   } 
};

class Recognizer
{
public:
  Recognizer(FILE* file);
  ~Recognizer();
  bool check(const char* type);  
  void advance();
  Lexeme* match(const char* type); 
  void matchNoAdvance(const char* type);
  Lexeme* getCurrentLexeme() { return currentLexeme; }
private:
  Lexeme* currentLexeme;
  Lex* m_Lex;
};

#endif